<!--
 * @Author: wrh123 482597539@qq.com
 * @Date: 2024-01-11 20:51:06
 * @LastEditors: wrh123 482597539@qq.com
 * @LastEditTime: 2024-01-21 15:17:12
 * @FilePath: /vue-admin/src/views/paying/components/addPaying.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="addPaying">
    <!-- addPaying -->
    <el-dialog title="编辑" :visible="dialogVisible" width="30%" :before-close="handleClose">
      <el-form ref="ruleForm" :model="arrt" :rules="rules" label-width="120px">
        <!--        <el-form-item label="账户类型">-->
        <!--          <el-select size="mini" placeholder="请选择账户类型">-->
        <!--            <el-option-->
        <!--              v-for="item in AccountType"-->
        <!--              :key="item.id"-->
        <!--              :label="item.name"-->
        <!--              :value="item.id"-->
        <!--            />-->
        <!--          </el-select>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="资助计划">-->
        <!--          <el-select size="mini" placeholder="请选择资助计划">-->
        <!--            <el-option-->
        <!--              v-for="item in sponsorship"-->
        <!--              :key="item.id"-->
        <!--              :label="item.name"-->
        <!--              :value="item.id"-->
        <!--            />-->
        <!--          </el-select>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="账户金额">-->
        <!--          <el-input size="mini" />-->
        <!--        </el-form-item>-->
        <el-form-item label="账户费用">
          <el-input size="mini" v-model="accountCharges" />
        </el-form-item>
        <!-- <el-form-item label="stripe支付名称">
          <el-input size="mini" v-model="cryptocurrencyName" />
        </el-form-item>
        <el-form-item label="stripe支付链接">
          <el-input size="mini" v-model="paymentConnection" />
        </el-form-item> -->
        <el-form-item>
          <el-row type="flex" justify="end" style="margin-top: 10px;">
            <el-button size="mini" @click="handleClose">取 消</el-button>
            <el-button size="mini" type="primary" @click="btnOK">保存</el-button>
          </el-row>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { getAccountType } from '@/api/Tradingacct'
import { getPayingList, updateAccountCharges } from "@/api/paying";

export default {
  name: 'VueAdminAddPaying',
  props: {
    dialogVisible: {
      default: false,
      type: Boolean
    },
    arrt: {
      type: Object,
      default() {
        return {}
      }
    },
    formPay: {
      type: Object,
      default() {
        return {}
      }
    },
    tableDataAll: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      accountCharges: null,
      // cryptocurrencyName: null,
      // paymentConnection: null,
      AccountType: [],
      tableData: {},
      rules: {},
      sponsorship: [
        {
          id: 1,
          name: '高风险'
        },
        {
          id: 2,
          name: '期货'
        },
        {
          id: 3,
          name: '美股'
        },
        {
          id: 4,
          name: '现货'
        }
      ]
    }
  },
  watch: {
    arrt(val) {
      this.tableData = val
      console.log("wwww", this.tableData)
      this.accountCharges = this.tableData.accountCharges
      // this.cryptocurrencyName = this.tableData.cryptocurrencyName
      // this.paymentConnection = this.tableData.paymentConnection
    },
  },
  computed: {
  },

  mounted() {
    // this.getAccountType()
    // this.getPayingListArr()
    // console.log("wwwww", this.tableData)
  },

  methods: {
    async getPayingListArr() {
      const data = await getPayingList(this.formPay)
      this.$emit('updateData', data.records, data.total); // 触发事件并传递数据
      // this.tableDataAll = data.records
      // this.total = data.total
      console.log(this.formPay, 'aaa', this.tableDataAll)
    },
    async getuseACCouyt() {
      const { data } = await getAccountType()
      this.AccountType = data
      console.log(data, '11')
    },
    // 取消
    handleClose() {
      this.$emit('update:dialogVisible', false)
      this.$refs.ruleForm.resetFields()
    },
    // 确定
    async btnOK() {
      this.arrt.accountCharges = this.accountCharges
      // this.arrt.cryptocurrencyName = this.cryptocurrencyName
      // this.arrt.paymentConnection = this.paymentConnection
      await updateAccountCharges(
        {
          id: this.arrt.id,
          accountCharges: this.arrt.accountCharges,
          // cryptocurrencyName: this.cryptocurrencyName,
          // paymentConnection: this.paymentConnection
        }
      )
      this.getPayingListArr()

      this.handleClose()
      this.$refs.ruleForm.resetFields()
      this.$message.success('操作成功')

    }
  }
}
</script>

<style lang="scss" scoped></style>
